package com.jyx.search.service;

import com.jyx.framework.domain.learning.JyxLearningCourse;
import com.jyx.framework.domain.learning.responses.LearningStatusResult;
import com.jyx.framework.model.response.CommonCode;
import com.jyx.search.dao.JyxLearningCourseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CourseQueryService {

    @Autowired
    JyxLearningCourseRepository jyxLearningCourseRepository;

    public LearningStatusResult getLearningStatusByIds(String courseId, String userId) {
        JyxLearningCourse jyxLearningCourse = jyxLearningCourseRepository.findJyxLearningCourseByCourseIdAndUserId(courseId, userId);
        if(jyxLearningCourse == null){
            return new LearningStatusResult(CommonCode.FAIL, null);
        }
        return new LearningStatusResult(CommonCode.SUCCESS, jyxLearningCourse);
    }
}
